﻿#include "ssWinConsole.h"

#ifdef SS_USE_WINDOWS

namespace StarSeeker
{

SS_SINGLETON_INIT(ssWinConsole)

ssWinConsole::ssWinConsole()
{
	// create a new console to the process
    AllocConsole();

	freopen("CONOUT$", "w+t", stdout);
	freopen("CONIN$", "r+t", stdin);

	printf("console all ready!\n");
}

ssWinConsole::~ssWinConsole()
{
	FreeConsole();
}

void ssWinConsole::Print(const char *str)
{
	printf(str);
}

void ssWinConsole::Printf(const char *strf, ...)
{
	// 处理变长参数
	va_list arglist;
	va_start(arglist, strf);
	vprintf(strf, arglist);
	va_end(arglist);
}

}
#endif
